home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Task / c++ / GuiGadget next >
Text File  |  2003-02-14  |  5KB  |  132 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #include "GuiGadget.h"
  39. #include "swis.h"
  40.  
  41. GuiToolboxGadget::GuiToolboxGadget(GuiWindow& window, GuiComponentId cid)
  42.  : m_window_id(window.id()),m_component_id(cid)
  43. {}
  44.  
  45. //******************************************************************
  46.  
  47. void GuiToolboxGadget::fade(bool is_fade)
  48. {
  49.   int flags=getFlags();
  50.  
  51.   if (is_fade) 
  52.   {
  53.     if ((flags & GuiToolboxGadget_Faded)==0) setFlags(flags | GuiToolboxGadget_Faded);
  54.   }
  55.   else
  56.   {
  57.     if (flags & GuiToolboxGadget_Faded) setFlags(flags &~ GuiToolboxGadget_Faded);
  58.   }
  59. }
  60.  
  61.  
  62. //******************************************************************
  63. //      GuiSlider
  64. //******************************************************************
  65.  
  66. void GuiSlider::setBounds(int flags,int lower_bound,int upper_bound,int step_size)
  67. {
  68.   // lower_bound/upper_bound other way around in book
  69.   _swix(Toolbox_ObjectMiscOp,_INR(0,6),
  70.                              flags,windowId(),578,componentId(),
  71.                              lower_bound,upper_bound,step_size);
  72. }
  73.  
  74.  
  75. //*****************************************************************
  76. //*****************************************************************
  77. //*****************************************************************
  78.  
  79. void set_component_string(GuiObjectId ob_id,GuiComponentId comp_id,int method_code,const char* str)
  80. {
  81.   if (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId)
  82.      _swix(Toolbox_ObjectMiscOp,_INR(0,4),0,ob_id,method_code,comp_id,str);
  83. }
  84.  
  85. //*****************************************************************
  86.  
  87. string get_component_string(GuiObjectId id,GuiComponentId cid,int method_code,int item)
  88. {
  89.   string s;
  90.   if (id != NULL_GuiObjectId && cid != NULL_GuiComponentId)
  91.      {
  92.      _kernel_swi_regs reg;
  93.      reg.r[0]=0;
  94.      reg.r[1]=id;
  95.      reg.r[2]=method_code;
  96.      reg.r[3]=cid;
  97.      reg.r[4]=0;
  98.      reg.r[5]=0;
  99.      reg.r[6]=item;
  100.      if (_kernel_swi(Toolbox_ObjectMiscOp,®,®)==NULL)
  101.         {
  102.         s.resize(reg.r[5]-1);
  103.         if (s.size()==reg.r[5]-1)
  104.            {
  105.            reg.r[4]=(int)s.data();
  106.            _kernel_swi(Toolbox_ObjectMiscOp,®,®);
  107.            }
  108.         }
  109.      }
  110.   return s;
  111. }
  112.  
  113. //*****************************************************************
  114.  
  115. void set_component_value(GuiObjectId ob_id,GuiComponentId comp_id,int method_code,int value)
  116. {
  117.   if (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId)
  118.       _swix(Toolbox_ObjectMiscOp,_INR(0,4),0,ob_id,method_code,comp_id,value);
  119. }
  120.  
  121.  
  122. //*****************************************************************
  123.  
  124. int get_component_value(GuiObjectId ob_id,GuiComponentId comp_id,int method_code)
  125. {
  126.   int val;
  127.   return (ob_id != NULL_GuiObjectId && comp_id != NULL_GuiComponentId &&
  128.           _swix(Toolbox_ObjectMiscOp,_INR(0,3) | _OUT(0),0,ob_id,method_code,comp_id,&val)==NULL)?
  129.           val:0;
  130. }
  131.  
  132.